package com.spring.boot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spring.boot.pojo.User;
import com.spring.boot.service.PetService;
import com.spring.boot.service.UserService;
//import com.spring.boot.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mc")
public class MyController {

    @Autowired
    PetService petService;
    @Autowired
    public UserService userService;

    @RequestMapping("/test")
    public Object test(@RequestParam("a") String a) {

        System.out.println(a);
        return "哈哈哈哈...........";
    }

    @RequestMapping("/getPet")
    public Object getPet() {
        return petService.getPet();
    }

    @RequestMapping("/getUser")
    public Object getUser(){

//        userService.

        return userService.getUser();
    }


    /**
     * mybatis-plus 分页查询
     * @param softName 查询的参数
     * @param page
     * @return
     */
    public Object getList(Page<User> page, String softName){
        Page<User> pages = userService.page(page,new QueryWrapper<User>()
                        .orderByDesc("version")
                        .groupBy("version")
                        .like("soft_name",softName)
                        .ne("version","select version from soft_info order by version desc limit 1")// 子查询
        );
        return pages;
    }




}
